<?php

class UserRecord extends TActiveRecord
{
	const TABLE = 'users';
	
	// fields
	/**
	 * @var integer $id
	 * @soapproperty
	 */
	public $id;
	public $login;
	public $password;
	public $first_name;
	public $last_name;
	public $email;
	public $registration;
	
	public function setId($id)                              { $this->id = $id; }
	public function setLogin($login)                        { $this->login = $login; }
	public function setPassword($password)                  { $this->password = $password; }
	public function setFirstName($first_name)               { $this->first_name = $first_name; }
	public function setLastName($last_name)                 { $this->last_name = $last_name; }
	public function setEmail($email)                        { $this->email = $email; }
	public function setRegistration($registration)          { $this->registration = $registration; }
	
	public function getId()             { return $this->id; }
	public function getLogin()          { return $this->login; }
	public function getPassword()       { return $this->password; }
	public function getFirstName()      { return $this->first_name; }
	public function getLastName()       { return $this->last_name; }
	public function getEmail()          { return $this->email; }
	public function getRegistration()   { return $this->registration; }
	
	public function getFullName()       { return $this->getFirstName().' '.$this->getLastName(); }
	
	public function setData($id, $login, $password, $first_name, $last_name, $email, $registration)
	{
		$this->id           = $id;
		$this->login        = $login;
		$this->password     = $password;
		$this->first_name   = $first_name;
		$this->last_name    = $last_name;
		$this->email        = $email;
		$this->registration = $registration;
	}
	
	public function setDataByUserRecord($record)
	{
		if($record instanceof UserRecord)
		{
			$this->setData(	$record->getId(), $record->getLogin(), $record->getPassword(),
							$record->getFirstName(), $record->getLastName(), $record->getEmail(),
							$record->getRegistration());
		}
	}
	
	public function equals($userRecord)
	{
		if($userRecord instanceof UserRecord)
		{
			return	$this->getLogin() == $userRecord->getLogin()			&&
					$this->getPassword() == $userRecord->getPassword()		&&
					$this->getFirstName() == $userRecord->getFirstName()	&&
					$this->getLastName() == $userRecord->getLastName()		&&
					$this->getEmail() == $userRecord->getEmail()			&&
					$this->getRegistration() == $userRecord->getRegistration();
		}
		return false;
	}
	
	public static function finder($className=__CLASS__)
	{
		return parent::finder($className);
	}
}

?>